from appium import webdriver
import unittest
from appium.webdriver.common.appiumby import AppiumBy

"""
    1、如果 想要 通过 python 编写  app 的自动化测试脚本  ，需要使用  appium 客户端的服务 以及 appium 的模块
    2、 pypi：pip install Appium-Python-Client
"""


class MyAppiumTestCase(unittest.TestCase):
    driver = None

    @classmethod
    def setUpClass(cls) -> None:
        desired_caps = dict(
            platformName='Android',
            deviceName='127.0.0.1:62001',
            appActivity='com.iBookStar.activityOff.Splash',
            appPackage='com.iBookStar.activityOff',
            noReset='true',
        )
        cls.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

        # 隐式等待
        cls.driver.implicitly_wait(30)

    def test_ibooks(self):
        print('i启动成功-----')
        # 点击  忽略 本次
        ignore = self.driver.find_element(AppiumBy.ID, "com.iBookStar.activityOff:id/cancel")
        print(ignore.text)
        print(ignore.is_enabled())
        ignore.click()


    @classmethod
    def tearDownClass(cls) -> None:
        # cls.driver.quit()
        pass


if __name__ == '__main__':
    unittest.main()
